﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace Data.Core.Repositories
{
    public interface IRepository<TEntity> : IDisposable
            where TEntity : class
    {
        TEntity FindBy(int id);
        bool TryFindBy(ref TEntity result, int id);
        bool Add(TEntity entity);
        bool Add(IEnumerable<TEntity> entities);
        bool Update(TEntity entity);
        bool Delete(TEntity entity);
        bool Delete(IEnumerable<TEntity> entities);
        IQueryable<TEntity> All();
        IList<TEntity> GetAll();
        TEntity FindBy(Expression<Func<TEntity, bool>> expression);
        bool TryFindBy(ref TEntity result, Expression<Func<TEntity, bool>> expression);
        IQueryable<TEntity> FilterBy(Expression<Func<TEntity, bool>> expression);
        void LoadProperty(Object ownerObject, Object property);
    }
}
